
/**
 * Created by losor on 2017/2/27.
 */
public class _476_NumberComplement {
    public static void main(String[] args) {
        System.out.println(findComplement(5));
    }

    public static int findComplement(int num) {
        String str = Integer.toBinaryString(num);
        StringBuilder strb = new StringBuilder();
        for (int i = 0; i < str.length(); i++) {
            if (str.charAt(i)=='1') {
                strb.append("0");
            }
            else {
                strb.append("1");
            }
        }
        System.out.println(strb.toString());
        int a = Integer.parseInt(strb.toString(),2);

        return a ;
    }

}
